package co.yixiang.hw.repository;

import co.yixiang.hw.domain.YxStoreOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

/**
* @author Walert
* @date 2020-02-13
*/
public interface YxStoreOrderRepository extends JpaRepository<YxStoreOrder, Integer>, JpaSpecificationExecutor<YxStoreOrder> {
    /**
    * 根据 Unique 查询
    * @param unique /
    * @return /
    */
    Optional<YxStoreOrder> findByUnique(String unique);

    YxStoreOrder findByIdAndIsDel(Integer id,Integer isDel);

    @Query(value = "select t.change_time from yx_store_order_status t where t.oid = ?1 and t.change_type = 'user_take_delivery'", nativeQuery = true)
    List<Integer> findOrderEndTime(Integer oid);

    List<YxStoreOrder> getByParentId(Integer parentId);


}